//-----------------------------------------------------------------------
// <copyright file="PersonEmailAddress.cs" company="Procure Development">
//     Copyright (c) Procure Development. All rights reserved.
// </copyright>
// <author>Victor Procure</author>
//-----------------------------------------------------------------------

using System.Linq;
using MongoDb.EntityFramework;
using MongoDB.Bson;using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using SManagement.Controllers;

namespace SManagement.Models{
    /// <summary>
    /// The electronic mail (e-mail) address for a person.
    /// </summary>
    public class PersonEmailAddress
    {
        #region Instance Properties
        [BsonId]
        public ObjectId _id { get; set; }

        public ObjectId PersonId { get; set; }

        public string EmailAddress { get; set; }

        public ObjectId? RefEmailTypeId { get; set; }

        #endregion Instance Properties
        public static string GetEmail(ObjectId personId)
        {
            return MongoDbContext.Current.Single<PersonEmailAddress>(s => s.PersonId == personId).EmailAddress;
        }
    }}